﻿using System;
using System.Threading;
using XcoAppSpaces.Contracts.Transport;
using XcoAppSpaces.Serialization.Binary;
using System.Diagnostics;

namespace test.XcoAppSpaces.Transport.WCF.Azure
{
    class ReceivedTmp
    {
        public Stopwatch StopWatch { get; set; }
   
        public int Sum
        { get { return sum; }
        }
        public ReceivedTmp()
        {
            StopWatch = new Stopwatch();
        }
        private XcoBinarySerializer ser1 = new XcoBinarySerializer();
        private int sum = 0;
        public ManualResetEvent WaitForStop { get; set; }

        public void MessageReceived(XcoMessage msg, string address, IXcoTransportService commService)
        {

            IntMsg n = (IntMsg) ser1.Deserialize(msg.Content);
            Interlocked.Add(ref sum, n.value);
            WaitForStop.Set();
        }
    }

    [Serializable]
    public class IntMsg
    {
        public int value;
        public string strValue;
    }
}
